﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WeChat.Controls
{
    /// <summary>
    /// PublicGlobalButton.xaml 的交互逻辑
    /// </summary>
    public partial class PublicGlobalButton : UserControl
    {
        public PublicGlobalButton()
        {
            InitializeComponent();
        }

        private void Button_Click_Close_Window(object sender, RoutedEventArgs e)
        {
            var myWindow = Window.GetWindow(this);
            myWindow.Close();
        }

        private void Min_Button_CliCK(object sender, RoutedEventArgs e)
        {
            var myWindow = Window.GetWindow(this);
            myWindow.WindowState = WindowState.Minimized;
        }

        private void Max_Button_CliCK(object sender, RoutedEventArgs e)
        {
            var myWindow = Window.GetWindow(this);
            myWindow.WindowState = myWindow.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
        }

        private void Top_Button_CliCK(object sender, RoutedEventArgs e)
        {
            var myWindow = Window.GetWindow(this);
            myWindow.Topmost = myWindow.Topmost == true ? false : true;
            Button topBtn = sender as Button;
            if (topBtn != null)
            {

                var bc = new BrushConverter();
                if (myWindow.Topmost)
                    //绿色
                    //topBtn.Foreground = new SolidColorBrush(Colors.Green);
                    //16进制
                    topBtn.Foreground = (Brush)bc.ConvertFrom("#07C160");
                else
                    //topBtn.Foreground = new SolidColorBrush(Colors.Gray);
                    topBtn.Foreground = (Brush)bc.ConvertFrom("#979797");
            }
        }
    }
}
